<%@ Page Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeFile="Posts.aspx.cs" Inherits="Posts" Title="Untitled Page" ValidateRequest="false" %>

<%@ Register Assembly="RadTabStrip.Net2" Namespace="Telerik.WebControls" TagPrefix="radTS" %>

<%@ Register Assembly="RadTreeView.Net2" Namespace="Telerik.WebControls" TagPrefix="radT" %>

<%@ Register Assembly="Acms.AcmsControls" Namespace="Acms.AcmsControls" TagPrefix="cc1" %>
<asp:Content ID="Content2" ContentPlaceHolderID="phActions" runat="server">
    <asp:LinkButton ID="btnAddNewPost" Text="Add New Post" CausesValidation="false" runat="server" />
    <asp:LinkButton ID="btnSelectPost" Text="Select Post" CausesValidation="false" runat="server" OnClick="btnSelectPost_Click" />
    <asp:LinkButton ID="btnEditPost" Text="Edit" CausesValidation="false" runat="server" OnClick="btnEditPost_Click" />
    <asp:LinkButton ID="btnSavePost" Text="Save" ValidationGroup="SavePost" runat="server" OnClick="btnSavePost_Click" />
    <asp:LinkButton ID="btnCancelPost" Text="Cancel" CausesValidation="false" runat="server" OnClick="btnCancelPost_Click" />
    <asp:LinkButton ID="btnAddChildPost" Text="Add Child" CausesValidation="false" runat="server" OnClick="btnAddChildPost_Click" />
    <asp:LinkButton ID="btnNewVersion" runat="server" OnClick="btnNewVersion_Click">Create New Version</asp:LinkButton>
    <asp:LinkButton ID="btnSaveTopics" Text="Save Topic Changes" runat="server" OnClick="btnSaveTopics_Click"/>
    <asp:LinkButton ID="btnSaveMenus" Text="Save Menu Changes" runat="server" OnClick="btnSaveMenus_Click"/>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="phMain" Runat="Server">
    <div id="divSiteMap" visible="false" runat="server">
        <fieldset>
            <legend>Site Map</legend>
            <div class="notes">Select the post that you want to edit</div>
            <asp:Label ID="lblReleases" runat="server" AssociatedControlID="ddlRelease" Text="Releases"></asp:Label>
            <asp:DropDownList ID="ddlRelease" AutoPostBack="true" OnSelectedIndexChanged="ddlRelease_SelectedIndexChanged" runat="server">
                <asp:ListItem Text="Pending" Value="Pending" />
                <asp:ListItem Text="Live" Value="Live" />
            </asp:DropDownList>
            <radT:RadTreeView ID="tvSiteMap2" DataFieldParentID="ParentId" DataTextField="DisplayName" DataValueField="VersionId" DragAndDrop="False" DataSourceID="dsSiteMap2" runat="server" OnNodeBound="tvSiteMap2_NodeBound" OnNodeClick="tvSiteMap2_NodeClick" AutoPostBack="True" >
            </radT:RadTreeView>
        </fieldset>
    </div>
    <div id="divDetails" visible="false" runat="server">
        <radTS:RadTabStrip ID="tabVersions" Skin="VerticalSimple" AutoPostBack="True" SelectedIndex="0" ClickSelectedTab="false" runat="server" DataSourceID="dsVersions" OnTabCreated="tabVersions_TabCreated" OnTabClick="tabVersions_TabClick" DataFieldID="StartDate" DataTextField="VersionName" DataValueField="VersionId" Orientation="VerticalLeftToRight">
        </radTS:RadTabStrip>
        <div class="verticalPage">
            <asp:Literal ID="litPageTitle" runat="server" />
            <radTS:RadTabStrip ID="tabs" MultiPageID="multiPage" Skin="WinVista" AutoPostBack="true" SelectedIndex="0" OnTabClick="tabs_TabClick" runat="server">
                <Tabs>
                    <radTS:Tab Text="Details" PageViewID="pageDetails"></radTS:Tab>
                    <radTS:Tab Text="Content" PageViewID="pageContent"></radTS:Tab>
                    <%--<radTS:Tab Text="Topics" PageViewID="pageTopics"/>
                    <radTS:Tab Text="Menus" PageViewID="pageMenus"/>
                    <radTS:Tab Text="Position" PageViewID="pagePosition"/>--%>
                    <radTS:Tab Text="Publishing" PageViewID="pagePublishPending"/>
                    <radTS:Tab Text="Publishing" PageViewID="pagePublishNonPending"/>
                </Tabs>
            </radTS:RadTabStrip>
            <radTS:RadMultiPage ID="multiPage" CssClass="horizontalPage" RenderSelectedPageOnly="true" SelectedIndex="0" runat="server">
                <radTS:PageView ID="pageDetails" runat="server">
                    <div id="divNoHomePage" visible="false" runat="server">There is no home page set up please create one.</div>
                <asp:DetailsView ID="dvPost" CssClass="adminDetails" runat="server" DataSourceID="dsPost" DataKeyNames="VersionId,ConcurencyId" AutoGenerateRows="False" OnItemInserted="dvPost_ItemInserted" OnItemUpdated="dvPost_ItemUpdated">
                    <Fields>
                        <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True"
                            SortExpression="Id" />
                        <asp:BoundField DataField="VersionId" HeaderText="VersionId" InsertVisible="False" ReadOnly="True"
                            SortExpression="VersionId" />
                        <acmswc:TextBoxField HeaderText="Name" DataField="Name" Required="True" RequiredValidationGroup="SavePost" OnTextBoxDataBound="dvPost_NameTextBoxDataBound"/>
                        <acmswc:TextBoxField HeaderText="Display Name" DataField="DisplayName" Required="True" RequiredValidationGroup="SavePost"/>
                        <asp:BoundField DataField="Path" HeaderText="Path" InsertVisible="False" ReadOnly="True"
                            SortExpression="Path" />
                        <asp:BoundField DataField="ParentPath" HeaderText="Parent Path" InsertVisible="False"
                            ReadOnly="True" SortExpression="ParentPath" />
                        <acmswc:DropDownListField HeaderText="Template" DataField="TemplateId" DisplayDataField="TemplateName" DataSourceId="dsTemplates" DataTextField="Name" DataValueField="Id" IncludeBlankOption="True" Required="True" RequiredValidationGroup="SavePost" />
                        <acmswc:TextBoxField HeaderText="Summary" DataField="Summary" MultiLine="True" Columns="50" Rows="10"/>
                        <asp:TemplateField HeaderText="Thumbnail">
                            <InsertItemTemplate>
                                <asp:FileUpload ID="fuThumb" runat="server" />
                            </InsertItemTemplate>
                            <EditItemTemplate>
                                <asp:FileUpload ID="fuThumb" runat="server" />
                                <br />
                                <acms:AcmsImage id="imgThumb" FileId='<%#Eval("ThumbnailId") %>' RenderHeight="50" RenderWidth="50" runat="server" />
                            </EditItemTemplate>
                            <ItemTemplate>
                                <acms:AcmsImage id="imgThumb" FileId='<%#Eval("ThumbnailId") %>' RenderHeight="50" RenderWidth="50" runat="server" />
                            </ItemTemplate>
                        </asp:TemplateField>
        <%--                
                        <asp:TemplateField HeaderText="Make Child">
                            <ItemTemplate>
                                <asp:Repeater ID="rptSiblings" runat="server" OnItemCommand="rptSiblings_ItemCommand">
                                    <HeaderTemplate><ul></HeaderTemplate>
                                    <ItemTemplate><li><asp:LinkButton ID="lnkSibling" CommandName="MakeChild" CommandArgument='<%#Eval("Value") %>' Text='<%#Eval("Text") %>' runat="server" /></li></ItemTemplate>
                                    <FooterTemplate></ul></FooterTemplate>
                                </asp:Repeater>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ShowHeader="False">
                            <EditItemTemplate>
                                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                                    Text="Update"></asp:LinkButton>
                                <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                                    Text="Cancel"></asp:LinkButton>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Insert"
                                    Text="Insert"></asp:LinkButton>
                                <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                                    Text="Cancel"></asp:LinkButton>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                                    Text="Edit"></asp:LinkButton>
                                <asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False" CommandName="Delete"
                                    Text="Delete"></asp:LinkButton>
                                <div class="listCommands">
                                    <asp:LinkButton ID="LinkButton2" CssClass="item" runat="server" CausesValidation="False" CommandName="AddChild"
                                    Text="Add Child"></asp:LinkButton>
                                    <asp:LinkButton ID="btnAddSibling" runat="server" CausesValidation="False" CommandName="AddSibling"
                                        CssClass="item" Text="Add Sibling"></asp:LinkButton>
                                    <asp:LinkButton ID="btnMoveUp"  CssClass="item" runat="server" OnClick="btnMoveUp_Click">Move Up</asp:LinkButton>
                                    <asp:LinkButton ID="btnMoveParent"  CssClass="item" runat="server" OnClick="btnMoveParent_Click">Move To Parent</asp:LinkButton>
                                </div>
                            </ItemTemplate>
                        </asp:TemplateField>
        --%>            </Fields>
                </asp:DetailsView>
                </radTS:PageView>
                <radTS:PageView ID="pageContent" runat="server">
                    <asp:DataList ID="dlPostControls" runat="server" DataSourceID="dsPostControls" RepeatLayout="Flow" OnEditCommand="dlPostControls_EditCommand" OnItemCreated="dlPostControls_ItemCreated" OnItemDataBound="dlPostControls_ItemDataBound" OnDataBinding="dlPostControls_DataBinding" OnCancelCommand="dlPostControls_CancelCommand" OnUpdateCommand="dlPostControls_UpdateCommand" OnDeleteCommand="dlPostControls_DeleteCommand">
                        <ItemTemplate>
                            <div>
                                <b><%# Eval("Name") %></b>
                                <%#Eval("Notes") %>
                                <div>
                                    <asp:Button ID="btnEdit" Text="Edit" CommandName="Edit" runat="server" />
                                    <asp:Button ID="btnDelete" Text="Delete" CommandName="Delete" OnClientClick="javascript:return confirm('Are you sure you want to delete?');" runat="server" />
                                </div>
                                <asp:Label ID="lblError" Visible="false" runat="server" />
                                <div style="background:LightGrey;">
                                    <asp:PlaceHolder ID="phControl" runat="server" />
                                </div>
                            </div>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <div>
                                <b><%# Eval("Name") %></b>
                                <%#Eval("Notes") %>
                                <div>
                                    <asp:Button ID="btnSave" Text="Save" CommandName="Update" runat="server" />
                                    <asp:Button ID="btnCancel" Text="Cancel" CommandName="Cancel" runat="server" />
                                </div>
                                <asp:Label ID="lblError" Visible="false" runat="server" />
                                <asp:PlaceHolder ID="phControl" runat="server" />
                            </div>
                        </EditItemTemplate>
                        <SeparatorTemplate><hr /></SeparatorTemplate>
                    </asp:DataList>
                    </radTS:PageView>
                <radTS:PageView ID="pageTopics" runat="server">
                    <acmswc:CheckBoxList ID="cblTopics" DataSourceID="dsTopics" runat="server" DataTextField="Name" DataValueField="Id" OnItemDataBound="cblTopics_ItemDataBound">
                    </acmswc:CheckBoxList>
                </radTS:PageView>
                <radTS:PageView ID="pageMenus" runat="server">
                    <acmswc:CheckBoxList id="cblMenus" DataSourceID="dsMenus" runat="server" DataTextField="Name" DataValueField="Id" DataCheckedField="DefaultForAllPosts" OnItemDataBound="cblMenus_ItemDataBound"/>
                </radTS:PageView>
                <radTS:PageView ID="pagePublishPending" runat="server">
                    <asp:LinkButton ID="lnkPublishPending" Text="Publish This Page" runat="server" />
                </radTS:PageView>
            </radTS:RadMultiPage>
        </div>
        <br style="clear:both" />
    </div>
    <div id="divAddWizard" runat="server">
        <asp:Wizard ID="wizAdd" runat="server">
            <WizardSteps>
                <asp:TemplatedWizardStep ID="stepSelectParent" runat="server">
                    <ContentTemplate>
                        <asp:Label ID ="lblSelectParentVersion" runat="server">
                        </asp:Label>
                        <asp:DropDownList ID="ddlSelectParentVersion" AutoPostBack="true" runat="server" >
                            <asp:ListItem Value="Pending" Text="Pending" />
                            <asp:ListItem Value="Live" Text="Live" />
                        </asp:DropDownList>
                        <radT:RadTreeView ID="tvSelectParent" DataSourceID="dsSiteMapSelectParent" runat="server" />
                    </ContentTemplate>
                </asp:TemplatedWizardStep> 
            </WizardSteps>
        </asp:Wizard>
    </div>
   <%-- <div>
        <div id="divMenus" visible="false" class="float:left;width:auto;" runat="server">
            <fieldset>
                <legend>Menus</legend>
                <asp:Button ID="btnSaveMenus" runat="server" OnClick="btnSaveMenus_Click" Text="Save Changes" />
            </fieldset>
        </div>
        <div id="divTopics" visible="false" class="float:left;width:auto;" runat="server">
            <fieldset>
                <legend>Topics</legend>
                <acmswc:CheckBoxList ID="cblTopics" DataSourceID="dsTopics" runat="server" DataTextField="Name" DataValueField="Id" OnItemDataBound="cblTopics_ItemDataBound">
                </acmswc:CheckBoxList>
                <asp:Button ID="btnSaveTopics" runat="server" OnClick="btnSaveTopics_Click" Text="Save Changes" />
            </fieldset>
        </div>
    </div>
    <div id="divControls" visible="false" runat="server">
        <fieldset><legend>Contents</legend>
            <asp:DataList ID="dlPostControls" runat="server" DataSourceID="dsPostControls" RepeatLayout="Flow" OnEditCommand="dlPostControls_EditCommand" OnItemCreated="dlPostControls_ItemCreated" OnItemDataBound="dlPostControls_ItemDataBound" OnDataBinding="dlPostControls_DataBinding" OnCancelCommand="dlPostControls_CancelCommand" OnUpdateCommand="dlPostControls_UpdateCommand" OnDeleteCommand="dlPostControls_DeleteCommand">
                <ItemTemplate>
                    <div style="min-width:75%">
                        <asp:Label ID="lblControlName" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
                        <asp:Button ID="btnEdit" Text="Edit" CommandName="Edit" runat="server" />
                        <asp:Button ID="btnDelete" Text="Delete" CommandName="Delete" OnClientClick="javascript:return confirm('Are you sure you want to delete?');" runat="server" />
                    </div>
                    <asp:Label ID="lblError" Visible="false" runat="server" />
                    <asp:PlaceHolder ID="phControl" runat="server" />
                    <hr />
                </ItemTemplate>
                <EditItemTemplate>
                    <div style="min-width:75%">
                        <asp:Label ID="lblControlName" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
                        <asp:Button ID="btnSave" Text="Save" CommandName="Update" runat="server" />
                        <asp:Button ID="btnCancel" Text="Cancel" CommandName="Cancel" runat="server" />
                    </div>
                    <asp:Label ID="lblError" Visible="false" runat="server" />
                    <asp:PlaceHolder ID="phControl" runat="server" />
                    <hr />
                </EditItemTemplate>
            </asp:DataList>&nbsp;
        </fieldset>
    </div>
    <div id="divUnusedControls" visible="false" title="Unused Post Controls" runat="server">
        <fieldset>
            <legend>Unused Contents</legend>
                <asp:DataList ID="dlUnused" DataSourceId="dsUnused" OnItemCreated="dlUnused_ItemCreated" OnItemDataBound="dlUnused_ItemDataBound"  runat="server">
                    <ItemTemplate>
                        <div>
                            <asp:Label ID="lblUnusedName" Text='<%#Eval("Name")%>' runat="server"/>
                        </div>
                        <asp:Label ID="lblError" Visible="false" runat="server" />
                        <asp:PlaceHolder ID="phControl" runat="server" />
                        <hr />
                    </ItemTemplate>
                </asp:DataList>
        </fieldset>
    </div>
    <asp:SiteMapDataSource ID="dsSiteMap" runat="server" SiteMapProvider="AcmsSiteMap" />
    <acmsdc:UnusedPostControlDataSource ID="dsUnused" runat="server" OnSelectData="dsUnused_SelectData" />--%>
    &nbsp;
    <acmsdc:AcmsSiteMapDataSource ID="dsSiteMap2" OnGetVersionTimeStamp="dsSiteMap2_GetVersionTimeStamp" runat="server" />
    <acmsdc:PostDataSource ID="dsPost" runat="server" OnSelectData="dsPost_SelectData" OnUpdatingData="dsPost_UpdatingData" OnUpdatedData="dsPost_UpdatedData" />
    <acmsdc:TemplateDataSource ID="dsTemplates" runat="server" OnSelectData="dsTemplates_SelectData"/>
    <acmsdc:PostControlDataSource ID="dsPostControls" runat="server" OnSelectData="dsPostControls_SelectData"/>
    <acmsdc:PostDataSource ID="dsVersions" runat="server" OnSelectData="dsVersions_SelectData"/>
    <acmsdc:TopicDataSource ID="dsTopics" runat="server" OnSelectData="dsTopics_SelectData" />
    <acmsdc:MenuDataSource ID="dsMenus" runat="server" OnSelectData="dsMenus_SelectData"/>
    <acmsdc:AcmsSiteMapDataSource ID="dsSiteMapSelectParent" runat="server" />
</asp:Content>

